<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>parsetInt 函数</title>
</head>
<body>
    <script>
        // let num1 = parseInt(prompt("第一个数:"));
        // let num2 = parseInt(prompt("第二个数:"));
        // console.log(num1 + num2)

        let str = "2,5,7,8,1";
        let arr = str.split(",");
        let sum = 0;
        for (const item of arr) {
            const num = parseInt(item);
            sum += num;
        }
        console.log("sum=",sum);
    </script>
</body>
</html>